package com.yzk.back.sysuser.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.yzk.back.sysuser.model.SysUser;
import com.yzk.back.sysuser.server.ISysUserSer;
import com.yzk.frame.action.BaseActionSupport;
import com.yzk.frame.utils.util.Page;

@Namespace("/")
@Results( { @Result(name = "ok", location = "/ok.jsp") })
public class SysuserAction extends BaseActionSupport<SysUser> {

	private static final long serialVersionUID = 8410439452096157487L;

	private Long id;
	private SysUser entity ;
	private ISysUserSer sysUserSerImp ;
	private Page<SysUser> page = new Page<SysUser>();
	
	@Override
	public SysUser getModel() {
		System.out.println("run getModel method");
		return entity;
	}

	@Override
	public String list() throws Exception {
		System.out.println("run list method");
		page = this.sysUserSerImp.getByPage(page);
		return "ok";
	}

	@Override
	public String input() throws Exception {
		System.out.println("run input method");
		return "ok";
	}

	@Override
	public String save() throws Exception {
		System.out.println("run save method");
		this.sysUserSerImp.save(entity) ;
		return "ok";
	}

	@Override
	public String delete() throws Exception {
		System.out.println("run delete method");
		this.sysUserSerImp.delUser(id) ;
		return "ok";
	}

	@Override
	protected void prepareModel() throws Exception {
		System.out.println("run prepareModel method");
		if(null!=id) {
			entity = this.sysUserSerImp.findById(id);
		} else {
			entity = new SysUser();
		}
		
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public SysUser getEntity() {
		return entity;
	}

	public void setEntity(SysUser entity) {
		this.entity = entity;
	}

	public ISysUserSer getSysUserSerImp() {
		return sysUserSerImp;
	}

	@Resource
	public void setSysUserSerImp(ISysUserSer sysUserSerImp) {
		this.sysUserSerImp = sysUserSerImp;
	}

	public Page<SysUser> getPage() {
		return page;
	}

	public void setPage(Page<SysUser> page) {
		this.page = page;
	}

}
